{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ffd374f6",
   "metadata": {},
   "source": [
    "# 非math包 数据测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "36437fd0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import math"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "f646a2f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "int(0.8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "766b0671",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.5"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "3/2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a968b0a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "5//2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "90f9e251",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "5%2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "188f2dba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tv = math.modf(100.005/0.005)\n",
    "tv[0] == 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "d37253f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0020000000000029204"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "100.007%0.005"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1b0d8bd2",
   "metadata": {},
   "outputs": [],
   "source": [
    "def features_price_rounding(price: float, minipoint: float):\n",
    "    newprice = price\n",
    "    \n",
    "    tv = math.modf(price/minipoint)\n",
    "#   price刚好是minipoint的整数倍\n",
    "    if tv[0] == 0:\n",
    "        return price\n",
    "    elif price%minipoint < minipoint/2:\n",
    "        newprice = price//0.005 * minipoint\n",
    "    elif price%minipoint > minipoint/2:\n",
    "        newprice = (price//0.005+1) * minipoint\n",
    "    \n",
    "    return newprice"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "4e4d38d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "100.005"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "features_price_rounding(100.004, 0.005)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "06fc85a2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
